﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using AspectCore.DynamicProxy;

namespace Aop_AspectCore.Core
{
    public class CustomInterceptorAttribute : AbstractInterceptorAttribute
    {
        public override async Task Invoke(AspectContext context, AspectDelegate next)
        {

            try
            {
                Console.WriteLine("服务调用之前");
                await next(context);//执行被拦截的方法
            }
            catch (Exception)
            {
                Console.WriteLine("调用时出现异常处理");
                throw;
            }
            finally
            {
                Console.WriteLine("服务调用之后处理");
            }
        }
    }
}
